package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by 沐风 on 2024/4/11 12:33
 */
@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品id查询对应套餐id
     * @param dishIds
     * @return
     */
    List<Long> getSetmeanlIdsByDishIds(List<Long> dishIds);

    /**
     * 批量添加套餐对应的菜品数据
     * @param setmealDishes
     */
    void addBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id批量删除套餐菜品表中对应数据
     * @param setmealIds
     */
    void deleteByIds(List<Long> setmealIds);

    /**
     * 根据套餐id查询对应菜品数据
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> queryBySetmealId(Long setmealId);

    /**
     * 先根据要删除的套餐的id删除套餐菜品表中保存的相关数据
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);
}
